/**
 *
 */

var app = getApp()
Page({
	data: {
		root:'',
		siteroot:app.setting.siteroot,
		att_url: app.setting.att_url,
		pagedata:[],
		action: '',
		pcd:{},
		birth:'',
		pagetitle:'签到' + '-' + app.setting.title,
		bannerHeight: Math.ceil(290.0 / 750.0 * getApp().screenWidth)
	},
	onReady: function (){
		var the = this
	},
	onShow: function (){
		var ssid=wx.getStorageSync('ssid');
		if(!ssid && !app.issession){
			app.util.session();
		}
	},
	onPullDownRefresh: function (){
		var the=this;
		var opt={};
		the.onLoad(opt);
		setTimeout(function(){
			wx.stopPullDownRefresh()
		},1000);
	},
	onLoad: function (options){
		var the =this
		wx.setNavigationBarTitle({'title':the.data.pagetitle});
			app.util.get(app.access,function(pagedata){
				console.log(pagedata);
				the.setData({
					pagedata:pagedata,
					date: pagedata.months[0].title,
					loading:false
				});
			});


	},
	bindDateChange: function(e) {
		var the=this
		app.util.post('core/member.qiandao/getmonth/',{month:e.detail.value},function(res){
			console.log(res);
			the.setData({
			  date: e.detail.value,
			 'pagedata.monthdata': res
			})
		});
	},
	 bindRegionChange: function (e) {
		//console.log('picker发送选择改变，携带值为', e.detail.value)
		this.setData({
		  pcd: e.detail.value
		})
	  },
	show_rule:function(){
		var pagedata=this.data.pagedata
		pagedata.show_rule=pagedata.show_rule==1?0:1;
		this.setData({
		  'pagedata.show_rule': pagedata.show_rule
		})
	},
	reward:function(e){
		var the=this
		var data=e.currentTarget.dataset;
		app.util.post('core/member.qiandao/reward/',data);
	},
	sign:function(){
		var the=this
		var pagedata=the.data.pagedata
		the.setData({
		  'pagedata.signed': true
		})
		app.util.post('core/member.qiandao/sign/',{});
	},
	formSubmit:function(e){
		var the =this
		var data=e.detail.value;
		data.pcd={}
		data.pcd.province=the.data.pcd[0]
		data.pcd.city=the.data.pcd[1]
		data.pcd.district=the.data.pcd[2]
		data.birth = the.data.birth
		console.log(data.birth);
		app.util.post('core/member.qiandao/post/',data);
	},
	click:function(evt){
		//用户点击事件 data.func 为方法名，data.params 为调用参数！
		var data=evt.currentTarget.dataset;
		//console.log(evt);
		app.util[data.func](data.params);
	},
})